home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / DUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  428 b   |  17 lines

  1. /* dup.c --- p 492 */
  2. #include <stdio.h>
  3. #include <io.h>
  4. char message[] = "Testing dup. This should appear on stdout\n";
  5. main()
  6. {
  7.     int newhandle;
  8.                     /* By default, stdout has handle 1.
  9.                      * creat another handle for stdout*/
  10.     if((newhandle = dup(1)) == -1)
  11.         perror("dup on handle 1 failed!");
  12.     else
  13.     {
  14.         printf("New handle for stdout is %d\n", newhandle);
  15.         write(newhandle, message, sizeof(message));
  16.     }
  17. }